package com.tengju.user.infrastructure.repository.club.convert;

import com.tengju.user.domain.model.club.UserZoneId;
import com.tengju.user.domain.model.club.UserZoneMemberInfo;
import com.tengju.user.domain.model.club.ZoneId;
import com.tengju.user.domain.model.user.UserId;
import com.tengju.user.domain.model.user.UserIdCode;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.UserZoneMemberDO;


public class UserZoneRelationConvert {

    public static UserZoneMemberInfo toModel(UserZoneMemberDO userZoneMemberDO) {

        if (userZoneMemberDO == null) {
            return null;
        }

        return new UserZoneMemberInfo(new UserZoneId(userZoneMemberDO.getId()),
                new ZoneId(userZoneMemberDO.getZoneID()),
                new UserIdCode(userZoneMemberDO.getMemberIdCode()),
                new UserId(userZoneMemberDO.getMemberUserId()));
    }

    public static UserZoneMemberDO modelToDO(UserZoneMemberInfo userZoneMemberInfo) {
        if (userZoneMemberInfo == null) {
            return null;
        }
        return new UserZoneMemberDO(userZoneMemberInfo.getUserZoneId() == null ? null : userZoneMemberInfo.getUserZoneId().getValue(),
                userZoneMemberInfo.getZoneId() == null ? null : userZoneMemberInfo.getZoneId().getValue(),
                userZoneMemberInfo.getUserIdCode() == null ? null : userZoneMemberInfo.getUserIdCode().getValue(),
                userZoneMemberInfo.getUserId() == null ? null : userZoneMemberInfo.getUserId().getValue(),
                null,
                null);

    }
}
